// pages/component/industry/industry.js
import utils from "../../../utils/util.js"
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    
  },
  options: {
    addGlobalClass: true,
  },

  /**
   * 组件的初始数据
   */
  data: {
    swiper:{
      videoText: [
        {
          "playTime": "02:00",
          "img": "../../../images/1.jpg",
          "title": "1站在牛市开端 蓝筹股依然有较大上涨空间1站在牛市开端 蓝筹股依然有较大上涨空间 ",
          "website": "凤凰网财经",
          "time": "1分钟前"
        },
        {
          "playTime": "03:00",
          "img": "../../../images/1.jpg",
          "title": "2站在牛市开端 蓝筹股依然有较大上涨空间 ",
          "website": "凤凰网财经",
          "time": "1分钟前"
        },
        {
          "playTime": "03:00",
          "img": "../../../images/1.jpg",
          "title": "3站在牛市开端 蓝筹股依然有较大上涨空间 ",
          "website": "凤凰网财经",
          "time": "1分钟前"
        },
        {
          "playTime": "03:00",
          "img": "../../../images/1.jpg",
          "title": "4站在牛市开端 蓝筹股依然有较大上涨空间 ",
          "website": "凤凰网财经",
          "time": "1分钟前"
        }
      ],
      autoplay: false,  //自动切换
      indicatorDots: false,  //是否显示面板指示点
      interval: 5000,   //自动切换时间间隔
      current: 0,   // 当前所在滑块的index
      isPreSlide: false,  //向左切换箭头是否可用
      isNextSlide: true  //向右切换箭头是否可用
    },
    gameSwiper:{  //互动游戏
      videoText:[
        {
          "img": "../../../images/1.jpg",
          "title":"1打击非法证券1打击非法证券",
          "dis":"情景类网页游戏"
        },
        {
          "img": "../../../images/1.jpg",
          "title": "2打击非法证券",
          "dis": "情景类网页游戏"
        },
        {
          "img": "../../../images/1.jpg",
          "title": "3打击非法证券",
          "dis": "情景类网页游戏"
        },
        {
          "img": "../../../images/1.jpg",
          "title": "4打击非法证券",
          "dis": "情景类网页游戏"
        },
        {
          "img": "../../../images/1.jpg",
          "title": "5打击非法证券",
          "dis": "情景类网页游戏"
        },
        {
          "img": "../../../images/1.jpg",
          "title": "6打击非法证券",
          "dis": "情景类网页游戏"
        }
      ],
      autoplay: false,  //自动切换
      indicatorDots: false,  //是否显示面板指示点
      interval: 5000,   //自动切换时间间隔
      current: 0,   // 当前所在滑块的index
      isPreSlide: false,  //向左切换箭头是否可用
      isNextSlide: true,  //向右切换箭头是否可用
      disItemNum:3,  //同时显示的滑块数量
    },
    countDown:"00:00:00",  //倒计时
    imgText: [  //产品赏析
      {
        "img": "../../../images/1.jpg",
        "title": "1站在牛市开端 蓝筹股依然有较大上涨空间1站在牛市开端 蓝筹股依然有较大上涨空间 ",
        "website": "凤凰网财经",
        "time": "1分钟前",
        "hotNum": "220",
        "collectNum": "200"
      },
      {
        "title": "2站在牛市开端 蓝筹股依然有较大上涨空间 ",
        "website": "凤凰网财经",
        "time": "1分钟前",
        "hotNum": "220",
        "collectNum": "200"
      },
      {
        "img": "../../../images/1.jpg",
        "title": "3站在牛市开端 蓝筹股依然有较大上涨空间 ",
        "website": "凤凰网财经",
        "time": "1分钟前",
        "hotNum": "220",
        "collectNum": "200"
      },
      {
        "img": "../../../images/1.jpg",
        "title": "4站在牛市开端 蓝筹股依然有较大上涨空间 ",
        "website": "凤凰网财经",
        "time": "1分钟前",
        "hotNum": "220",
        "collectNum": "200"
      }
    ],
    imgText2: [  //最新赏析
      {
        "img": "../../../images/1.jpg",
        "title": "21站在牛市开端 蓝筹股依然有较大上涨空间1站在牛市开端 蓝筹股依然有较大上涨空间 ",
        "website": "凤凰网财经",
        "time": "1分钟前",
        "hotNum": "220",
        "collectNum": "200"
      },
      {
        "title": "22站在牛市开端 蓝筹股依然有较大上涨空间 ",
        "website": "凤凰网财经",
        "time": "1分钟前",
        "hotNum": "220",
        "collectNum": "200"
      },
      {
        "img": "../../../images/1.jpg",
        "title": "23站在牛市开端 蓝筹股依然有较大上涨空间 ",
        "website": "凤凰网财经",
        "time": "1分钟前",
        "hotNum": "220",
        "collectNum": "200"
      },
      {
        "img": "../../../images/1.jpg",
        "title": "24站在牛市开端 蓝筹股依然有较大上涨空间 ",
        "website": "凤凰网财经",
        "time": "1分钟前",
        "hotNum": "220",
        "collectNum": "200"
      }
    ],
    titleBox:[
      {
        "title":"产品赏析"
      },
      {
        "title":"最新活动"
      }
    ],
    state:'0',  //产品赏析和最新活动tab切换标记
  },

  /**
   * 组件的方法列表
   */
  methods: {
    // swiper切换到上一个
    prevImg() {
      let { swiper} = this.data;
      let current = swiper.current;
      let isPreSlide = swiper.isPreSlide;
      let isNextSlide = swiper.isNextSlide;

      if (current <= 0) {
        isPreSlide = false;
        isNextSlide = true
      } else {
        isPreSlide = true;
        isNextSlide = true;
      }
      swiper.current = current > 0 ? current - 1 : current;

      let swiper2 = Object.assign({}, swiper, { isPreSlide }, { isNextSlide});

      this.setData({
        swiper: swiper2
      })
    },
    // swiper切换到下一个
    nextImg(){      
      let {swiper} = this.data;
      let current = swiper.current;
      let isPreSlide = swiper.isPreSlide;
      let isNextSlide = swiper.isNextSlide;

      if (current == swiper.videoText.length - 1 || current == swiper.videoText.length - 2) {
        isNextSlide = false;
        isPreSlide = true;
      } else {
        isNextSlide = true;
        isPreSlide = true;
      }
      swiper.current = current < (swiper.videoText.length - 1) ? current + 1 : swiper.videoText.length - 1;

      let swiper2 = Object.assign({}, swiper, { isPreSlide }, { isNextSlide });

      this.setData({
        swiper: swiper2
      })
    },
    // 游戏swiper切换到上一个
    preSlide() {
      let { gameSwiper } = this.data;
      let current = gameSwiper.current;
      let isPreSlide = gameSwiper.isPreSlide;
      let isNextSlide = gameSwiper.isNextSlide;

      if (current <= 0) {
        isPreSlide = false;
        isNextSlide = true
      } else {
        isPreSlide = true;
        isNextSlide = true;
      }
      gameSwiper.current = current > 0 ? current - 1 : current;

      let swiper2 = Object.assign({}, gameSwiper, { isPreSlide }, { isNextSlide });

      this.setData({
        gameSwiper: swiper2
      })
      console.log(current);
    },
    // 游戏swiper切换到下一个
    nextSlide() {
      let { gameSwiper } = this.data;
      let current = gameSwiper.current;
      let isPreSlide = gameSwiper.isPreSlide;
      let isNextSlide = gameSwiper.isNextSlide;

      if (current == gameSwiper.videoText.length - 3) {
        isNextSlide = false;
        isPreSlide = true;
      } else {
        isNextSlide = true;
        isPreSlide = true;
      }
      gameSwiper.current = current < (gameSwiper.videoText.length - 3) ? current + 1 : gameSwiper.videoText.length - 3;

      let swiper2 = Object.assign({}, gameSwiper, { isPreSlide }, { isNextSlide });

      this.setData({
        gameSwiper: swiper2
      })
    },
    //tab切换
    changeTitle(e) {
      let index = e.target.dataset.index;
      this.setData({
        state: index
      })
    },
    //跳转到详情页
    todetails(){
      wx.navigateTo({
        url: '../../pages/newsDetails/newsDetails',
      })
    }
  }
})
